package activity

import (
	"activity_srv/activityclient"
	"api/internal/respons"
	"context"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetGrouponProductDetailLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetGrouponProductDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetGrouponProductDetailLogic {
	return &GetGrouponProductDetailLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetGrouponProductDetailLogic) GetGrouponProductDetail(req *types.GetGrouponProductDetailRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	detail, err := l.svcCtx.ActivityRpc.GetGrouponProductDetail(l.ctx, &activityclient.GetGrouponProductDetailRequest{
		Id: req.Id,
	})
	if err != nil {
		return respons.Error(400, "获取拼团商品详情失败", err.Error()), err

	}
	return respons.Success(detail), nil
}
